package com.crayon.account.loader;

import android.content.Context;
import android.support.v4.content.AsyncTaskLoader;

import com.crayon.account.dao.DAOFood;
import com.crayon.account.dao.DAOTable;
import com.crayon.account.dao.DataBaseManager;
import com.crayon.util.GDB;
import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.stmt.QueryBuilder;

import java.util.LinkedList;
import java.util.List;

public class LoaderSQLFoodSelect extends AsyncTaskLoader<List<DAOFood>> {


	public LoaderSQLFoodSelect(Context context) {
		super(context);
	}

	@Override
	public List<DAOFood> loadInBackground() {

		DataBaseManager baseManager =DataBaseManager.getHelper(getContext());

		try {

			Dao<DAOFood, Integer> daoFood =baseManager.getDAOFood();

			QueryBuilder<DAOFood, Integer> builder = daoFood.queryBuilder();
			return builder.query();
		}catch(Exception e ){
			GDB.log(getClass(), "result search err " + e.getMessage());
		}
		return null;
	}

//	@Override
//	protected void onStartLoading() {
//		// TODO Auto-generated method stub
//		super.onStartLoading();
//		forceLoad();
//	}


}


